// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#[cfg(feature = "assistant-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "assistant-service")))]
pub mod assistant_service {
    use crate::Result;

    /// A builder for [AssistantService][crate::client::AssistantService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::assistant_service::ClientBuilder;
    /// # use client::AssistantService;
    /// let builder : ClientBuilder = AssistantService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::AssistantService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = AssistantService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::AssistantService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::AssistantService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AssistantService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [AssistantService::list_operations][crate::client::AssistantService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::assistant_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AssistantService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [AssistantService::get_operation][crate::client::AssistantService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::assistant_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AssistantService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [AssistantService::cancel_operation][crate::client::AssistantService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::assistant_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AssistantService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "cmek-config-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "cmek-config-service")))]
pub mod cmek_config_service {
    use crate::Result;

    /// A builder for [CmekConfigService][crate::client::CmekConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::cmek_config_service::ClientBuilder;
    /// # use client::CmekConfigService;
    /// let builder : ClientBuilder = CmekConfigService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::CmekConfigService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = CmekConfigService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::CmekConfigService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [CmekConfigService::update_cmek_config][crate::client::CmekConfigService::update_cmek_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::UpdateCmekConfig;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateCmekConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateCmekConfig(RequestBuilder<crate::model::UpdateCmekConfigRequest>);

    impl UpdateCmekConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateCmekConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [update_cmek_config][crate::client::CmekConfigService::update_cmek_config].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .update_cmek_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `update_cmek_config`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::CmekConfig, crate::model::UpdateCmekConfigMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::CmekConfig,
                crate::model::UpdateCmekConfigMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [config][crate::model::UpdateCmekConfigRequest::config].
        ///
        /// This is a **required** field for requests.
        pub fn set_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CmekConfig>,
        {
            self.0.request.config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [config][crate::model::UpdateCmekConfigRequest::config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CmekConfig>,
        {
            self.0.request.config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [set_default][crate::model::UpdateCmekConfigRequest::set_default].
        pub fn set_set_default<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.set_default = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateCmekConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::get_cmek_config][crate::client::CmekConfigService::get_cmek_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::GetCmekConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetCmekConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetCmekConfig(RequestBuilder<crate::model::GetCmekConfigRequest>);

    impl GetCmekConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetCmekConfigRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CmekConfig> {
            (*self.0.stub)
                .get_cmek_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetCmekConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetCmekConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::list_cmek_configs][crate::client::CmekConfigService::list_cmek_configs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::ListCmekConfigs;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListCmekConfigs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListCmekConfigs(RequestBuilder<crate::model::ListCmekConfigsRequest>);

    impl ListCmekConfigs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListCmekConfigsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListCmekConfigsResponse> {
            (*self.0.stub)
                .list_cmek_configs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::ListCmekConfigsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListCmekConfigs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::delete_cmek_config][crate::client::CmekConfigService::delete_cmek_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::DeleteCmekConfig;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteCmekConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteCmekConfig(RequestBuilder<crate::model::DeleteCmekConfigRequest>);

    impl DeleteCmekConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteCmekConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_cmek_config][crate::client::CmekConfigService::delete_cmek_config].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_cmek_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_cmek_config`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteCmekConfigMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteCmekConfigMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteCmekConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteCmekConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::list_operations][crate::client::CmekConfigService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::get_operation][crate::client::CmekConfigService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CmekConfigService::cancel_operation][crate::client::CmekConfigService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::cmek_config_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CmekConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "completion-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "completion-service")))]
pub mod completion_service {
    use crate::Result;

    /// A builder for [CompletionService][crate::client::CompletionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::completion_service::ClientBuilder;
    /// # use client::CompletionService;
    /// let builder : ClientBuilder = CompletionService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::CompletionService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = CompletionService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::CompletionService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [CompletionService::complete_query][crate::client::CompletionService::complete_query] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::CompleteQuery;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CompleteQuery {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CompleteQuery(RequestBuilder<crate::model::CompleteQueryRequest>);

    impl CompleteQuery {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CompleteQueryRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CompleteQueryResponse> {
            (*self.0.stub)
                .complete_query(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [data_store][crate::model::CompleteQueryRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.data_store = v.into();
            self
        }

        /// Sets the value of [query][crate::model::CompleteQueryRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [query_model][crate::model::CompleteQueryRequest::query_model].
        pub fn set_query_model<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query_model = v.into();
            self
        }

        /// Sets the value of [user_pseudo_id][crate::model::CompleteQueryRequest::user_pseudo_id].
        pub fn set_user_pseudo_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_pseudo_id = v.into();
            self
        }

        /// Sets the value of [include_tail_suggestions][crate::model::CompleteQueryRequest::include_tail_suggestions].
        pub fn set_include_tail_suggestions<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.include_tail_suggestions = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CompleteQuery {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::import_suggestion_deny_list_entries][crate::client::CompletionService::import_suggestion_deny_list_entries] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::ImportSuggestionDenyListEntries;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportSuggestionDenyListEntries {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportSuggestionDenyListEntries(
        RequestBuilder<crate::model::ImportSuggestionDenyListEntriesRequest>,
    );

    impl ImportSuggestionDenyListEntries {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportSuggestionDenyListEntriesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_suggestion_deny_list_entries][crate::client::CompletionService::import_suggestion_deny_list_entries].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_suggestion_deny_list_entries(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_suggestion_deny_list_entries`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::ImportSuggestionDenyListEntriesResponse,
            crate::model::ImportSuggestionDenyListEntriesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::ImportSuggestionDenyListEntriesResponse,
                crate::model::ImportSuggestionDenyListEntriesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportSuggestionDenyListEntriesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportSuggestionDenyListEntriesRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<
            T: Into<Option<crate::model::import_suggestion_deny_list_entries_request::Source>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportSuggestionDenyListEntriesRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<
                        crate::model::import_suggestion_deny_list_entries_request::InlineSource,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportSuggestionDenyListEntriesRequest::source]
        /// to hold a `GcsSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportSuggestionDenyListEntries {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::purge_suggestion_deny_list_entries][crate::client::CompletionService::purge_suggestion_deny_list_entries] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::PurgeSuggestionDenyListEntries;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeSuggestionDenyListEntries {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeSuggestionDenyListEntries(
        RequestBuilder<crate::model::PurgeSuggestionDenyListEntriesRequest>,
    );

    impl PurgeSuggestionDenyListEntries {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeSuggestionDenyListEntriesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_suggestion_deny_list_entries][crate::client::CompletionService::purge_suggestion_deny_list_entries].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_suggestion_deny_list_entries(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_suggestion_deny_list_entries`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::PurgeSuggestionDenyListEntriesResponse,
            crate::model::PurgeSuggestionDenyListEntriesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::PurgeSuggestionDenyListEntriesResponse,
                crate::model::PurgeSuggestionDenyListEntriesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeSuggestionDenyListEntriesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeSuggestionDenyListEntries {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::import_completion_suggestions][crate::client::CompletionService::import_completion_suggestions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::ImportCompletionSuggestions;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportCompletionSuggestions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportCompletionSuggestions(
        RequestBuilder<crate::model::ImportCompletionSuggestionsRequest>,
    );

    impl ImportCompletionSuggestions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportCompletionSuggestionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_completion_suggestions][crate::client::CompletionService::import_completion_suggestions].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_completion_suggestions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_completion_suggestions`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::ImportCompletionSuggestionsResponse,
            crate::model::ImportCompletionSuggestionsMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::ImportCompletionSuggestionsResponse,
                crate::model::ImportCompletionSuggestionsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportCompletionSuggestionsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [error_config][crate::model::ImportCompletionSuggestionsRequest::error_config].
        pub fn set_error_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error_config][crate::model::ImportCompletionSuggestionsRequest::error_config].
        pub fn set_or_clear_error_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [source][crate::model::ImportCompletionSuggestionsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<
            T: Into<Option<crate::model::import_completion_suggestions_request::Source>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportCompletionSuggestionsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<
                        crate::model::import_completion_suggestions_request::InlineSource,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportCompletionSuggestionsRequest::source]
        /// to hold a `GcsSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportCompletionSuggestionsRequest::source]
        /// to hold a `BigquerySource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_bigquery_source<
            T: std::convert::Into<std::boxed::Box<crate::model::BigQuerySource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_bigquery_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportCompletionSuggestions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::purge_completion_suggestions][crate::client::CompletionService::purge_completion_suggestions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::PurgeCompletionSuggestions;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeCompletionSuggestions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeCompletionSuggestions(
        RequestBuilder<crate::model::PurgeCompletionSuggestionsRequest>,
    );

    impl PurgeCompletionSuggestions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeCompletionSuggestionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_completion_suggestions][crate::client::CompletionService::purge_completion_suggestions].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_completion_suggestions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_completion_suggestions`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::PurgeCompletionSuggestionsResponse,
            crate::model::PurgeCompletionSuggestionsMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::PurgeCompletionSuggestionsResponse,
                crate::model::PurgeCompletionSuggestionsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeCompletionSuggestionsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeCompletionSuggestions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::list_operations][crate::client::CompletionService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::get_operation][crate::client::CompletionService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::cancel_operation][crate::client::CompletionService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::completion_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "control-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "control-service")))]
pub mod control_service {
    use crate::Result;

    /// A builder for [ControlService][crate::client::ControlService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::control_service::ClientBuilder;
    /// # use client::ControlService;
    /// let builder : ClientBuilder = ControlService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ControlService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ControlService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ControlService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ControlService::create_control][crate::client::ControlService::create_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::CreateControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateControl(RequestBuilder<crate::model::CreateControlRequest>);

    impl CreateControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .create_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateControlRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [control][crate::model::CreateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_control<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [control][crate::model::CreateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = v.map(|x| x.into());
            self
        }

        /// Sets the value of [control_id][crate::model::CreateControlRequest::control_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_control_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.control_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::delete_control][crate::client::ControlService::delete_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::DeleteControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteControl(RequestBuilder<crate::model::DeleteControlRequest>);

    impl DeleteControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteControlRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::update_control][crate::client::ControlService::update_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::UpdateControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateControl(RequestBuilder<crate::model::UpdateControlRequest>);

    impl UpdateControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .update_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [control][crate::model::UpdateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_control<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [control][crate::model::UpdateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateControlRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateControlRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::get_control][crate::client::ControlService::get_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::GetControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetControl(RequestBuilder<crate::model::GetControlRequest>);

    impl GetControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .get_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetControlRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::list_controls][crate::client::ControlService::list_controls] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::ListControls;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListControls {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListControls(RequestBuilder<crate::model::ListControlsRequest>);

    impl ListControls {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListControlsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListControlsResponse> {
            (*self.0.stub)
                .list_controls(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListControlsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListControlsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListControlsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListControlsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListControlsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListControlsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListControls {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::list_operations][crate::client::ControlService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::get_operation][crate::client::ControlService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::cancel_operation][crate::client::ControlService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::control_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "conversational-search-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "conversational-search-service")))]
pub mod conversational_search_service {
    use crate::Result;

    /// A builder for [ConversationalSearchService][crate::client::ConversationalSearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::conversational_search_service::ClientBuilder;
    /// # use client::ConversationalSearchService;
    /// let builder : ClientBuilder = ConversationalSearchService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ConversationalSearchService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ConversationalSearchService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ConversationalSearchService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ConversationalSearchService::converse_conversation][crate::client::ConversationalSearchService::converse_conversation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::ConverseConversation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ConverseConversation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ConverseConversation(RequestBuilder<crate::model::ConverseConversationRequest>);

    impl ConverseConversation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ConverseConversationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ConverseConversationResponse> {
            (*self.0.stub)
                .converse_conversation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::ConverseConversationRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [query][crate::model::ConverseConversationRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_query<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::TextInput>,
        {
            self.0.request.query = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query][crate::model::ConverseConversationRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_query<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::TextInput>,
        {
            self.0.request.query = v.map(|x| x.into());
            self
        }

        /// Sets the value of [serving_config][crate::model::ConverseConversationRequest::serving_config].
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [conversation][crate::model::ConverseConversationRequest::conversation].
        pub fn set_conversation<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [conversation][crate::model::ConverseConversationRequest::conversation].
        pub fn set_or_clear_conversation<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = v.map(|x| x.into());
            self
        }

        /// Sets the value of [safe_search][crate::model::ConverseConversationRequest::safe_search].
        pub fn set_safe_search<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.safe_search = v.into();
            self
        }

        /// Sets the value of [user_labels][crate::model::ConverseConversationRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [summary_spec][crate::model::ConverseConversationRequest::summary_spec].
        pub fn set_summary_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::content_search_spec::SummarySpec>,
        {
            self.0.request.summary_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [summary_spec][crate::model::ConverseConversationRequest::summary_spec].
        pub fn set_or_clear_summary_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::content_search_spec::SummarySpec>,
        {
            self.0.request.summary_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [filter][crate::model::ConverseConversationRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [boost_spec][crate::model::ConverseConversationRequest::boost_spec].
        pub fn set_boost_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [boost_spec][crate::model::ConverseConversationRequest::boost_spec].
        pub fn set_or_clear_boost_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ConverseConversation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::create_conversation][crate::client::ConversationalSearchService::create_conversation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::CreateConversation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateConversation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateConversation(RequestBuilder<crate::model::CreateConversationRequest>);

    impl CreateConversation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateConversationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Conversation> {
            (*self.0.stub)
                .create_conversation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateConversationRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [conversation][crate::model::CreateConversationRequest::conversation].
        ///
        /// This is a **required** field for requests.
        pub fn set_conversation<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [conversation][crate::model::CreateConversationRequest::conversation].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_conversation<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateConversation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::delete_conversation][crate::client::ConversationalSearchService::delete_conversation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::DeleteConversation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteConversation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteConversation(RequestBuilder<crate::model::DeleteConversationRequest>);

    impl DeleteConversation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteConversationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_conversation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteConversationRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteConversation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::update_conversation][crate::client::ConversationalSearchService::update_conversation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::UpdateConversation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateConversation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateConversation(RequestBuilder<crate::model::UpdateConversationRequest>);

    impl UpdateConversation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateConversationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Conversation> {
            (*self.0.stub)
                .update_conversation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [conversation][crate::model::UpdateConversationRequest::conversation].
        ///
        /// This is a **required** field for requests.
        pub fn set_conversation<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [conversation][crate::model::UpdateConversationRequest::conversation].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_conversation<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Conversation>,
        {
            self.0.request.conversation = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateConversationRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateConversationRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateConversation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::get_conversation][crate::client::ConversationalSearchService::get_conversation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::GetConversation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetConversation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetConversation(RequestBuilder<crate::model::GetConversationRequest>);

    impl GetConversation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetConversationRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Conversation> {
            (*self.0.stub)
                .get_conversation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetConversationRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetConversation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::list_conversations][crate::client::ConversationalSearchService::list_conversations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::ListConversations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListConversations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListConversations(RequestBuilder<crate::model::ListConversationsRequest>);

    impl ListConversations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListConversationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListConversationsResponse> {
            (*self.0.stub)
                .list_conversations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListConversationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListConversationsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListConversationsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListConversationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListConversationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListConversationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::ListConversationsRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListConversations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::answer_query][crate::client::ConversationalSearchService::answer_query] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::AnswerQuery;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AnswerQuery {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AnswerQuery(RequestBuilder<crate::model::AnswerQueryRequest>);

    impl AnswerQuery {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AnswerQueryRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AnswerQueryResponse> {
            (*self.0.stub)
                .answer_query(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::AnswerQueryRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [query][crate::model::AnswerQueryRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_query<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Query>,
        {
            self.0.request.query = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query][crate::model::AnswerQueryRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_query<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Query>,
        {
            self.0.request.query = v.map(|x| x.into());
            self
        }

        /// Sets the value of [session][crate::model::AnswerQueryRequest::session].
        pub fn set_session<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.session = v.into();
            self
        }

        /// Sets the value of [safety_spec][crate::model::AnswerQueryRequest::safety_spec].
        pub fn set_safety_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::SafetySpec>,
        {
            self.0.request.safety_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [safety_spec][crate::model::AnswerQueryRequest::safety_spec].
        pub fn set_or_clear_safety_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::SafetySpec>,
        {
            self.0.request.safety_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [related_questions_spec][crate::model::AnswerQueryRequest::related_questions_spec].
        pub fn set_related_questions_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::RelatedQuestionsSpec>,
        {
            self.0.request.related_questions_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [related_questions_spec][crate::model::AnswerQueryRequest::related_questions_spec].
        pub fn set_or_clear_related_questions_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::RelatedQuestionsSpec>,
        {
            self.0.request.related_questions_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [grounding_spec][crate::model::AnswerQueryRequest::grounding_spec].
        pub fn set_grounding_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::GroundingSpec>,
        {
            self.0.request.grounding_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [grounding_spec][crate::model::AnswerQueryRequest::grounding_spec].
        pub fn set_or_clear_grounding_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::GroundingSpec>,
        {
            self.0.request.grounding_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [answer_generation_spec][crate::model::AnswerQueryRequest::answer_generation_spec].
        pub fn set_answer_generation_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::AnswerGenerationSpec>,
        {
            self.0.request.answer_generation_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [answer_generation_spec][crate::model::AnswerQueryRequest::answer_generation_spec].
        pub fn set_or_clear_answer_generation_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::AnswerGenerationSpec>,
        {
            self.0.request.answer_generation_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [search_spec][crate::model::AnswerQueryRequest::search_spec].
        pub fn set_search_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::SearchSpec>,
        {
            self.0.request.search_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [search_spec][crate::model::AnswerQueryRequest::search_spec].
        pub fn set_or_clear_search_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::SearchSpec>,
        {
            self.0.request.search_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [query_understanding_spec][crate::model::AnswerQueryRequest::query_understanding_spec].
        pub fn set_query_understanding_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::QueryUnderstandingSpec>,
        {
            self.0.request.query_understanding_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query_understanding_spec][crate::model::AnswerQueryRequest::query_understanding_spec].
        pub fn set_or_clear_query_understanding_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::QueryUnderstandingSpec>,
        {
            self.0.request.query_understanding_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [asynchronous_mode][crate::model::AnswerQueryRequest::asynchronous_mode].
        #[deprecated]
        pub fn set_asynchronous_mode<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.asynchronous_mode = v.into();
            self
        }

        /// Sets the value of [user_pseudo_id][crate::model::AnswerQueryRequest::user_pseudo_id].
        pub fn set_user_pseudo_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_pseudo_id = v.into();
            self
        }

        /// Sets the value of [user_labels][crate::model::AnswerQueryRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [end_user_spec][crate::model::AnswerQueryRequest::end_user_spec].
        pub fn set_end_user_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::EndUserSpec>,
        {
            self.0.request.end_user_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [end_user_spec][crate::model::AnswerQueryRequest::end_user_spec].
        pub fn set_or_clear_end_user_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::answer_query_request::EndUserSpec>,
        {
            self.0.request.end_user_spec = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AnswerQuery {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::get_answer][crate::client::ConversationalSearchService::get_answer] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::GetAnswer;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetAnswer {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetAnswer(RequestBuilder<crate::model::GetAnswerRequest>);

    impl GetAnswer {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetAnswerRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Answer> {
            (*self.0.stub)
                .get_answer(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetAnswerRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetAnswer {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::create_session][crate::client::ConversationalSearchService::create_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::CreateSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSession(RequestBuilder<crate::model::CreateSessionRequest>);

    impl CreateSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .create_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateSessionRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [session][crate::model::CreateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_session<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session][crate::model::CreateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::delete_session][crate::client::ConversationalSearchService::delete_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::DeleteSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSession(RequestBuilder<crate::model::DeleteSessionRequest>);

    impl DeleteSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteSessionRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::update_session][crate::client::ConversationalSearchService::update_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::UpdateSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateSession(RequestBuilder<crate::model::UpdateSessionRequest>);

    impl UpdateSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .update_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [session][crate::model::UpdateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_session<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session][crate::model::UpdateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateSessionRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateSessionRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::get_session][crate::client::ConversationalSearchService::get_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::GetSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSession(RequestBuilder<crate::model::GetSessionRequest>);

    impl GetSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .get_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetSessionRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [include_answer_details][crate::model::GetSessionRequest::include_answer_details].
        pub fn set_include_answer_details<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.include_answer_details = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::list_sessions][crate::client::ConversationalSearchService::list_sessions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::ListSessions;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSessions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSessions(RequestBuilder<crate::model::ListSessionsRequest>);

    impl ListSessions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSessionsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSessionsResponse> {
            (*self.0.stub)
                .list_sessions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSessionsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSessionsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListSessionsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSessionsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSessionsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListSessionsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::ListSessionsRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSessions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::list_operations][crate::client::ConversationalSearchService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::get_operation][crate::client::ConversationalSearchService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::cancel_operation][crate::client::ConversationalSearchService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::conversational_search_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "data-store-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "data-store-service")))]
pub mod data_store_service {
    use crate::Result;

    /// A builder for [DataStoreService][crate::client::DataStoreService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::data_store_service::ClientBuilder;
    /// # use client::DataStoreService;
    /// let builder : ClientBuilder = DataStoreService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::DataStoreService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = DataStoreService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::DataStoreService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [DataStoreService::create_data_store][crate::client::DataStoreService::create_data_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::CreateDataStore;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateDataStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateDataStore(RequestBuilder<crate::model::CreateDataStoreRequest>);

    impl CreateDataStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateDataStoreRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_data_store][crate::client::DataStoreService::create_data_store].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_data_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_data_store`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::DataStore, crate::model::CreateDataStoreMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::DataStore,
                crate::model::CreateDataStoreMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateDataStoreRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [data_store][crate::model::CreateDataStoreRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::DataStore>,
        {
            self.0.request.data_store = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [data_store][crate::model::CreateDataStoreRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_data_store<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::DataStore>,
        {
            self.0.request.data_store = v.map(|x| x.into());
            self
        }

        /// Sets the value of [data_store_id][crate::model::CreateDataStoreRequest::data_store_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.data_store_id = v.into();
            self
        }

        /// Sets the value of [create_advanced_site_search][crate::model::CreateDataStoreRequest::create_advanced_site_search].
        pub fn set_create_advanced_site_search<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.create_advanced_site_search = v.into();
            self
        }

        /// Sets the value of [skip_default_schema_creation][crate::model::CreateDataStoreRequest::skip_default_schema_creation].
        pub fn set_skip_default_schema_creation<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.skip_default_schema_creation = v.into();
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateDataStoreRequest::cmek_options].
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_cmek_options<
            T: Into<Option<crate::model::create_data_store_request::CmekOptions>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.cmek_options = v.into();
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateDataStoreRequest::cmek_options]
        /// to hold a `CmekConfigName`.
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_cmek_config_name<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_cmek_config_name(v);
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateDataStoreRequest::cmek_options]
        /// to hold a `DisableCmek`.
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_disable_cmek<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
            self.0.request = self.0.request.set_disable_cmek(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateDataStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::get_data_store][crate::client::DataStoreService::get_data_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::GetDataStore;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetDataStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetDataStore(RequestBuilder<crate::model::GetDataStoreRequest>);

    impl GetDataStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetDataStoreRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::DataStore> {
            (*self.0.stub)
                .get_data_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetDataStoreRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetDataStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::list_data_stores][crate::client::DataStoreService::list_data_stores] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::ListDataStores;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListDataStores {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListDataStores(RequestBuilder<crate::model::ListDataStoresRequest>);

    impl ListDataStores {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListDataStoresRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListDataStoresResponse> {
            (*self.0.stub)
                .list_data_stores(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListDataStoresResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListDataStoresResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListDataStoresRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListDataStoresRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListDataStoresRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListDataStoresRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListDataStores {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::delete_data_store][crate::client::DataStoreService::delete_data_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::DeleteDataStore;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteDataStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteDataStore(RequestBuilder<crate::model::DeleteDataStoreRequest>);

    impl DeleteDataStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteDataStoreRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_data_store][crate::client::DataStoreService::delete_data_store].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_data_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_data_store`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteDataStoreMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteDataStoreMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteDataStoreRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteDataStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::update_data_store][crate::client::DataStoreService::update_data_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::UpdateDataStore;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateDataStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateDataStore(RequestBuilder<crate::model::UpdateDataStoreRequest>);

    impl UpdateDataStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateDataStoreRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::DataStore> {
            (*self.0.stub)
                .update_data_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [data_store][crate::model::UpdateDataStoreRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::DataStore>,
        {
            self.0.request.data_store = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [data_store][crate::model::UpdateDataStoreRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_data_store<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::DataStore>,
        {
            self.0.request.data_store = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateDataStoreRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateDataStoreRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateDataStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::list_operations][crate::client::DataStoreService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::get_operation][crate::client::DataStoreService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DataStoreService::cancel_operation][crate::client::DataStoreService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::data_store_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "document-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "document-service")))]
pub mod document_service {
    use crate::Result;

    /// A builder for [DocumentService][crate::client::DocumentService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::document_service::ClientBuilder;
    /// # use client::DocumentService;
    /// let builder : ClientBuilder = DocumentService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::DocumentService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = DocumentService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::DocumentService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [DocumentService::get_document][crate::client::DocumentService::get_document] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::GetDocument;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetDocument {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetDocument(RequestBuilder<crate::model::GetDocumentRequest>);

    impl GetDocument {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetDocumentRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Document> {
            (*self.0.stub)
                .get_document(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetDocumentRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetDocument {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::list_documents][crate::client::DocumentService::list_documents] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::ListDocuments;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListDocuments {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListDocuments(RequestBuilder<crate::model::ListDocumentsRequest>);

    impl ListDocuments {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListDocumentsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListDocumentsResponse> {
            (*self.0.stub)
                .list_documents(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListDocumentsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListDocumentsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListDocumentsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListDocumentsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListDocumentsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListDocuments {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::create_document][crate::client::DocumentService::create_document] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::CreateDocument;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateDocument {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateDocument(RequestBuilder<crate::model::CreateDocumentRequest>);

    impl CreateDocument {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateDocumentRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Document> {
            (*self.0.stub)
                .create_document(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateDocumentRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [document][crate::model::CreateDocumentRequest::document].
        ///
        /// This is a **required** field for requests.
        pub fn set_document<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Document>,
        {
            self.0.request.document = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [document][crate::model::CreateDocumentRequest::document].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Document>,
        {
            self.0.request.document = v.map(|x| x.into());
            self
        }

        /// Sets the value of [document_id][crate::model::CreateDocumentRequest::document_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_document_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.document_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateDocument {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::update_document][crate::client::DocumentService::update_document] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::UpdateDocument;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateDocument {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateDocument(RequestBuilder<crate::model::UpdateDocumentRequest>);

    impl UpdateDocument {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateDocumentRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Document> {
            (*self.0.stub)
                .update_document(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [document][crate::model::UpdateDocumentRequest::document].
        ///
        /// This is a **required** field for requests.
        pub fn set_document<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Document>,
        {
            self.0.request.document = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [document][crate::model::UpdateDocumentRequest::document].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Document>,
        {
            self.0.request.document = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::UpdateDocumentRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateDocumentRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateDocumentRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateDocument {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::delete_document][crate::client::DocumentService::delete_document] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::DeleteDocument;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteDocument {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteDocument(RequestBuilder<crate::model::DeleteDocumentRequest>);

    impl DeleteDocument {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteDocumentRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_document(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteDocumentRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteDocument {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::import_documents][crate::client::DocumentService::import_documents] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::ImportDocuments;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportDocuments {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportDocuments(RequestBuilder<crate::model::ImportDocumentsRequest>);

    impl ImportDocuments {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportDocumentsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_documents][crate::client::DocumentService::import_documents].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_documents(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_documents`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::ImportDocumentsResponse, crate::model::ImportDocumentsMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::ImportDocumentsResponse,
                crate::model::ImportDocumentsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportDocumentsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [error_config][crate::model::ImportDocumentsRequest::error_config].
        pub fn set_error_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error_config][crate::model::ImportDocumentsRequest::error_config].
        pub fn set_or_clear_error_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [reconciliation_mode][crate::model::ImportDocumentsRequest::reconciliation_mode].
        pub fn set_reconciliation_mode<
            T: Into<crate::model::import_documents_request::ReconciliationMode>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.reconciliation_mode = v.into();
            self
        }

        /// Sets the value of [update_mask][crate::model::ImportDocumentsRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::ImportDocumentsRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [auto_generate_ids][crate::model::ImportDocumentsRequest::auto_generate_ids].
        pub fn set_auto_generate_ids<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.auto_generate_ids = v.into();
            self
        }

        /// Sets the value of [id_field][crate::model::ImportDocumentsRequest::id_field].
        pub fn set_id_field<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.id_field = v.into();
            self
        }

        /// Sets the value of [force_refresh_content][crate::model::ImportDocumentsRequest::force_refresh_content].
        pub fn set_force_refresh_content<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force_refresh_content = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<T: Into<Option<crate::model::import_documents_request::Source>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::import_documents_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `GcsSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `BigquerySource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_bigquery_source<
            T: std::convert::Into<std::boxed::Box<crate::model::BigQuerySource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_bigquery_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `FhirStoreSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_fhir_store_source<
            T: std::convert::Into<std::boxed::Box<crate::model::FhirStoreSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_fhir_store_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `SpannerSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_spanner_source<
            T: std::convert::Into<std::boxed::Box<crate::model::SpannerSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_spanner_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `CloudSqlSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_cloud_sql_source<
            T: std::convert::Into<std::boxed::Box<crate::model::CloudSqlSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_cloud_sql_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `FirestoreSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_firestore_source<
            T: std::convert::Into<std::boxed::Box<crate::model::FirestoreSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_firestore_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `AlloyDbSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_alloy_db_source<
            T: std::convert::Into<std::boxed::Box<crate::model::AlloyDbSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_alloy_db_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportDocumentsRequest::source]
        /// to hold a `BigtableSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_bigtable_source<
            T: std::convert::Into<std::boxed::Box<crate::model::BigtableSource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_bigtable_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportDocuments {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::purge_documents][crate::client::DocumentService::purge_documents] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::PurgeDocuments;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeDocuments {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeDocuments(RequestBuilder<crate::model::PurgeDocumentsRequest>);

    impl PurgeDocuments {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeDocumentsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_documents][crate::client::DocumentService::purge_documents].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_documents(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_documents`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::PurgeDocumentsResponse, crate::model::PurgeDocumentsMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::PurgeDocumentsResponse,
                crate::model::PurgeDocumentsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeDocumentsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PurgeDocumentsRequest::filter].
        ///
        /// This is a **required** field for requests.
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [error_config][crate::model::PurgeDocumentsRequest::error_config].
        pub fn set_error_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::PurgeErrorConfig>,
        {
            self.0.request.error_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error_config][crate::model::PurgeDocumentsRequest::error_config].
        pub fn set_or_clear_error_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::PurgeErrorConfig>,
        {
            self.0.request.error_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [force][crate::model::PurgeDocumentsRequest::force].
        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force = v.into();
            self
        }

        /// Sets the value of [source][crate::model::PurgeDocumentsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<T: Into<Option<crate::model::purge_documents_request::Source>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::PurgeDocumentsRequest::source]
        /// to hold a `GcsSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_source(v);
            self
        }

        /// Sets the value of [source][crate::model::PurgeDocumentsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::purge_documents_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeDocuments {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::batch_get_documents_metadata][crate::client::DocumentService::batch_get_documents_metadata] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::BatchGetDocumentsMetadata;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchGetDocumentsMetadata {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchGetDocumentsMetadata(
        RequestBuilder<crate::model::BatchGetDocumentsMetadataRequest>,
    );

    impl BatchGetDocumentsMetadata {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchGetDocumentsMetadataRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::BatchGetDocumentsMetadataResponse> {
            (*self.0.stub)
                .batch_get_documents_metadata(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::BatchGetDocumentsMetadataRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [matcher][crate::model::BatchGetDocumentsMetadataRequest::matcher].
        ///
        /// This is a **required** field for requests.
        pub fn set_matcher<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::batch_get_documents_metadata_request::Matcher>,
        {
            self.0.request.matcher = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [matcher][crate::model::BatchGetDocumentsMetadataRequest::matcher].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_matcher<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::batch_get_documents_metadata_request::Matcher>,
        {
            self.0.request.matcher = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchGetDocumentsMetadata {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::list_operations][crate::client::DocumentService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::get_operation][crate::client::DocumentService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [DocumentService::cancel_operation][crate::client::DocumentService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::document_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::DocumentService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "engine-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "engine-service")))]
pub mod engine_service {
    use crate::Result;

    /// A builder for [EngineService][crate::client::EngineService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::engine_service::ClientBuilder;
    /// # use client::EngineService;
    /// let builder : ClientBuilder = EngineService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::EngineService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = EngineService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::EngineService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [EngineService::create_engine][crate::client::EngineService::create_engine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::CreateEngine;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateEngine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateEngine(RequestBuilder<crate::model::CreateEngineRequest>);

    impl CreateEngine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateEngineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_engine][crate::client::EngineService::create_engine].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_engine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_engine`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Engine, crate::model::CreateEngineMetadata> {
            type Operation =
                lro::internal::Operation<crate::model::Engine, crate::model::CreateEngineMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateEngineRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [engine][crate::model::CreateEngineRequest::engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_engine<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Engine>,
        {
            self.0.request.engine = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [engine][crate::model::CreateEngineRequest::engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_engine<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Engine>,
        {
            self.0.request.engine = v.map(|x| x.into());
            self
        }

        /// Sets the value of [engine_id][crate::model::CreateEngineRequest::engine_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_engine_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.engine_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateEngine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::delete_engine][crate::client::EngineService::delete_engine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::DeleteEngine;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteEngine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteEngine(RequestBuilder<crate::model::DeleteEngineRequest>);

    impl DeleteEngine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteEngineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_engine][crate::client::EngineService::delete_engine].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_engine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_engine`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteEngineMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteEngineMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteEngineRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteEngine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::update_engine][crate::client::EngineService::update_engine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::UpdateEngine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateEngine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateEngine(RequestBuilder<crate::model::UpdateEngineRequest>);

    impl UpdateEngine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateEngineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Engine> {
            (*self.0.stub)
                .update_engine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [engine][crate::model::UpdateEngineRequest::engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_engine<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Engine>,
        {
            self.0.request.engine = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [engine][crate::model::UpdateEngineRequest::engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_engine<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Engine>,
        {
            self.0.request.engine = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateEngineRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateEngineRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateEngine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::get_engine][crate::client::EngineService::get_engine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::GetEngine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetEngine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetEngine(RequestBuilder<crate::model::GetEngineRequest>);

    impl GetEngine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetEngineRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Engine> {
            (*self.0.stub)
                .get_engine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetEngineRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetEngine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::list_engines][crate::client::EngineService::list_engines] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::ListEngines;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListEngines {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListEngines(RequestBuilder<crate::model::ListEnginesRequest>);

    impl ListEngines {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListEnginesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListEnginesResponse> {
            (*self.0.stub)
                .list_engines(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListEnginesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListEnginesResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListEnginesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListEnginesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListEnginesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListEnginesRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListEngines {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::list_operations][crate::client::EngineService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::get_operation][crate::client::EngineService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [EngineService::cancel_operation][crate::client::EngineService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::engine_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::EngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "grounded-generation-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "grounded-generation-service")))]
pub mod grounded_generation_service {
    use crate::Result;

    /// A builder for [GroundedGenerationService][crate::client::GroundedGenerationService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::grounded_generation_service::ClientBuilder;
    /// # use client::GroundedGenerationService;
    /// let builder : ClientBuilder = GroundedGenerationService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::GroundedGenerationService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = GroundedGenerationService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::GroundedGenerationService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [GroundedGenerationService::generate_grounded_content][crate::client::GroundedGenerationService::generate_grounded_content] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::grounded_generation_service::GenerateGroundedContent;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GenerateGroundedContent {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GenerateGroundedContent(
        RequestBuilder<crate::model::GenerateGroundedContentRequest>,
    );

    impl GenerateGroundedContent {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GenerateGroundedContentRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GenerateGroundedContentResponse> {
            (*self.0.stub)
                .generate_grounded_content(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [location][crate::model::GenerateGroundedContentRequest::location].
        ///
        /// This is a **required** field for requests.
        pub fn set_location<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.location = v.into();
            self
        }

        /// Sets the value of [system_instruction][crate::model::GenerateGroundedContentRequest::system_instruction].
        pub fn set_system_instruction<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::GroundedGenerationContent>,
        {
            self.0.request.system_instruction = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [system_instruction][crate::model::GenerateGroundedContentRequest::system_instruction].
        pub fn set_or_clear_system_instruction<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::GroundedGenerationContent>,
        {
            self.0.request.system_instruction = v.map(|x| x.into());
            self
        }

        /// Sets the value of [contents][crate::model::GenerateGroundedContentRequest::contents].
        pub fn set_contents<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::GroundedGenerationContent>,
        {
            use std::iter::Iterator;
            self.0.request.contents = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [generation_spec][crate::model::GenerateGroundedContentRequest::generation_spec].
        pub fn set_generation_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::generate_grounded_content_request::GenerationSpec>,
        {
            self.0.request.generation_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [generation_spec][crate::model::GenerateGroundedContentRequest::generation_spec].
        pub fn set_or_clear_generation_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::generate_grounded_content_request::GenerationSpec>,
        {
            self.0.request.generation_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [grounding_spec][crate::model::GenerateGroundedContentRequest::grounding_spec].
        pub fn set_grounding_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::generate_grounded_content_request::GroundingSpec>,
        {
            self.0.request.grounding_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [grounding_spec][crate::model::GenerateGroundedContentRequest::grounding_spec].
        pub fn set_or_clear_grounding_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::generate_grounded_content_request::GroundingSpec>,
        {
            self.0.request.grounding_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [user_labels][crate::model::GenerateGroundedContentRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GenerateGroundedContent {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GroundedGenerationService::check_grounding][crate::client::GroundedGenerationService::check_grounding] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::grounded_generation_service::CheckGrounding;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CheckGrounding {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CheckGrounding(RequestBuilder<crate::model::CheckGroundingRequest>);

    impl CheckGrounding {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CheckGroundingRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CheckGroundingResponse> {
            (*self.0.stub)
                .check_grounding(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [grounding_config][crate::model::CheckGroundingRequest::grounding_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_grounding_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.grounding_config = v.into();
            self
        }

        /// Sets the value of [answer_candidate][crate::model::CheckGroundingRequest::answer_candidate].
        pub fn set_answer_candidate<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.answer_candidate = v.into();
            self
        }

        /// Sets the value of [facts][crate::model::CheckGroundingRequest::facts].
        pub fn set_facts<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::GroundingFact>,
        {
            use std::iter::Iterator;
            self.0.request.facts = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [grounding_spec][crate::model::CheckGroundingRequest::grounding_spec].
        pub fn set_grounding_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CheckGroundingSpec>,
        {
            self.0.request.grounding_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [grounding_spec][crate::model::CheckGroundingRequest::grounding_spec].
        pub fn set_or_clear_grounding_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CheckGroundingSpec>,
        {
            self.0.request.grounding_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [user_labels][crate::model::CheckGroundingRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CheckGrounding {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GroundedGenerationService::list_operations][crate::client::GroundedGenerationService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::grounded_generation_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GroundedGenerationService::get_operation][crate::client::GroundedGenerationService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::grounded_generation_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GroundedGenerationService::cancel_operation][crate::client::GroundedGenerationService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::grounded_generation_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GroundedGenerationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "identity-mapping-store-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "identity-mapping-store-service")))]
pub mod identity_mapping_store_service {
    use crate::Result;

    /// A builder for [IdentityMappingStoreService][crate::client::IdentityMappingStoreService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::identity_mapping_store_service::ClientBuilder;
    /// # use client::IdentityMappingStoreService;
    /// let builder : ClientBuilder = IdentityMappingStoreService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::IdentityMappingStoreService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = IdentityMappingStoreService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::IdentityMappingStoreService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [IdentityMappingStoreService::create_identity_mapping_store][crate::client::IdentityMappingStoreService::create_identity_mapping_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::CreateIdentityMappingStore;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateIdentityMappingStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateIdentityMappingStore(
        RequestBuilder<crate::model::CreateIdentityMappingStoreRequest>,
    );

    impl CreateIdentityMappingStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateIdentityMappingStoreRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::IdentityMappingStore> {
            (*self.0.stub)
                .create_identity_mapping_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateIdentityMappingStoreRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [identity_mapping_store_id][crate::model::CreateIdentityMappingStoreRequest::identity_mapping_store_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_identity_mapping_store_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.identity_mapping_store_id = v.into();
            self
        }

        /// Sets the value of [identity_mapping_store][crate::model::CreateIdentityMappingStoreRequest::identity_mapping_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_identity_mapping_store<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::IdentityMappingStore>,
        {
            self.0.request.identity_mapping_store = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [identity_mapping_store][crate::model::CreateIdentityMappingStoreRequest::identity_mapping_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_identity_mapping_store<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::IdentityMappingStore>,
        {
            self.0.request.identity_mapping_store = v.map(|x| x.into());
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateIdentityMappingStoreRequest::cmek_options].
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_cmek_options<
            T: Into<Option<crate::model::create_identity_mapping_store_request::CmekOptions>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.cmek_options = v.into();
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateIdentityMappingStoreRequest::cmek_options]
        /// to hold a `CmekConfigName`.
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_cmek_config_name<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_cmek_config_name(v);
            self
        }

        /// Sets the value of [cmek_options][crate::model::CreateIdentityMappingStoreRequest::cmek_options]
        /// to hold a `DisableCmek`.
        ///
        /// Note that all the setters affecting `cmek_options` are
        /// mutually exclusive.
        pub fn set_disable_cmek<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
            self.0.request = self.0.request.set_disable_cmek(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateIdentityMappingStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::get_identity_mapping_store][crate::client::IdentityMappingStoreService::get_identity_mapping_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::GetIdentityMappingStore;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetIdentityMappingStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetIdentityMappingStore(
        RequestBuilder<crate::model::GetIdentityMappingStoreRequest>,
    );

    impl GetIdentityMappingStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetIdentityMappingStoreRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::IdentityMappingStore> {
            (*self.0.stub)
                .get_identity_mapping_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetIdentityMappingStoreRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetIdentityMappingStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::delete_identity_mapping_store][crate::client::IdentityMappingStoreService::delete_identity_mapping_store] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::DeleteIdentityMappingStore;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteIdentityMappingStore {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteIdentityMappingStore(
        RequestBuilder<crate::model::DeleteIdentityMappingStoreRequest>,
    );

    impl DeleteIdentityMappingStore {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteIdentityMappingStoreRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_identity_mapping_store][crate::client::IdentityMappingStoreService::delete_identity_mapping_store].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_identity_mapping_store(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_identity_mapping_store`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<(), crate::model::DeleteIdentityMappingStoreMetadata> {
            type Operation = lro::internal::Operation<
                wkt::Empty,
                crate::model::DeleteIdentityMappingStoreMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteIdentityMappingStoreRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteIdentityMappingStore {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::import_identity_mappings][crate::client::IdentityMappingStoreService::import_identity_mappings] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::ImportIdentityMappings;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportIdentityMappings {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportIdentityMappings(RequestBuilder<crate::model::ImportIdentityMappingsRequest>);

    impl ImportIdentityMappings {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportIdentityMappingsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_identity_mappings][crate::client::IdentityMappingStoreService::import_identity_mappings].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_identity_mappings(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_identity_mappings`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::ImportIdentityMappingsResponse,
            crate::model::IdentityMappingEntryOperationMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::ImportIdentityMappingsResponse,
                crate::model::IdentityMappingEntryOperationMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [identity_mapping_store][crate::model::ImportIdentityMappingsRequest::identity_mapping_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_identity_mapping_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.identity_mapping_store = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportIdentityMappingsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<
            T: Into<Option<crate::model::import_identity_mappings_request::Source>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportIdentityMappingsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::import_identity_mappings_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportIdentityMappings {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::purge_identity_mappings][crate::client::IdentityMappingStoreService::purge_identity_mappings] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::PurgeIdentityMappings;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeIdentityMappings {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeIdentityMappings(RequestBuilder<crate::model::PurgeIdentityMappingsRequest>);

    impl PurgeIdentityMappings {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeIdentityMappingsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_identity_mappings][crate::client::IdentityMappingStoreService::purge_identity_mappings].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_identity_mappings(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_identity_mappings`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<(), crate::model::IdentityMappingEntryOperationMetadata> {
            type Operation = lro::internal::Operation<
                wkt::Empty,
                crate::model::IdentityMappingEntryOperationMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [identity_mapping_store][crate::model::PurgeIdentityMappingsRequest::identity_mapping_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_identity_mapping_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.identity_mapping_store = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PurgeIdentityMappingsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [force][crate::model::PurgeIdentityMappingsRequest::force].
        pub fn set_force<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [force][crate::model::PurgeIdentityMappingsRequest::force].
        pub fn set_or_clear_force<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<bool>,
        {
            self.0.request.force = v.map(|x| x.into());
            self
        }

        /// Sets the value of [source][crate::model::PurgeIdentityMappingsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<
            T: Into<Option<crate::model::purge_identity_mappings_request::Source>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::PurgeIdentityMappingsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::purge_identity_mappings_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeIdentityMappings {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::list_identity_mappings][crate::client::IdentityMappingStoreService::list_identity_mappings] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::ListIdentityMappings;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListIdentityMappings {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListIdentityMappings(RequestBuilder<crate::model::ListIdentityMappingsRequest>);

    impl ListIdentityMappings {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListIdentityMappingsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListIdentityMappingsResponse> {
            (*self.0.stub)
                .list_identity_mappings(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListIdentityMappingsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListIdentityMappingsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [identity_mapping_store][crate::model::ListIdentityMappingsRequest::identity_mapping_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_identity_mapping_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.identity_mapping_store = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListIdentityMappingsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListIdentityMappingsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListIdentityMappings {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::list_identity_mapping_stores][crate::client::IdentityMappingStoreService::list_identity_mapping_stores] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::ListIdentityMappingStores;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListIdentityMappingStores {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListIdentityMappingStores(
        RequestBuilder<crate::model::ListIdentityMappingStoresRequest>,
    );

    impl ListIdentityMappingStores {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListIdentityMappingStoresRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListIdentityMappingStoresResponse> {
            (*self.0.stub)
                .list_identity_mapping_stores(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<
            crate::model::ListIdentityMappingStoresResponse,
            gax::error::Error,
        > {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListIdentityMappingStoresResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListIdentityMappingStoresRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListIdentityMappingStoresRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListIdentityMappingStoresRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListIdentityMappingStores {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::list_operations][crate::client::IdentityMappingStoreService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::get_operation][crate::client::IdentityMappingStoreService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [IdentityMappingStoreService::cancel_operation][crate::client::IdentityMappingStoreService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::identity_mapping_store_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::IdentityMappingStoreService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "project-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "project-service")))]
pub mod project_service {
    use crate::Result;

    /// A builder for [ProjectService][crate::client::ProjectService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::project_service::ClientBuilder;
    /// # use client::ProjectService;
    /// let builder : ClientBuilder = ProjectService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ProjectService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ProjectService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ProjectService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ProjectService::provision_project][crate::client::ProjectService::provision_project] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::project_service::ProvisionProject;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ProvisionProject {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ProvisionProject(RequestBuilder<crate::model::ProvisionProjectRequest>);

    impl ProvisionProject {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ProvisionProjectRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [provision_project][crate::client::ProjectService::provision_project].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .provision_project(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `provision_project`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Project, crate::model::ProvisionProjectMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::Project,
                crate::model::ProvisionProjectMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [name][crate::model::ProvisionProjectRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [accept_data_use_terms][crate::model::ProvisionProjectRequest::accept_data_use_terms].
        ///
        /// This is a **required** field for requests.
        pub fn set_accept_data_use_terms<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.accept_data_use_terms = v.into();
            self
        }

        /// Sets the value of [data_use_terms_version][crate::model::ProvisionProjectRequest::data_use_terms_version].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_use_terms_version<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.data_use_terms_version = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ProvisionProject {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProjectService::list_operations][crate::client::ProjectService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::project_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProjectService::get_operation][crate::client::ProjectService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::project_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProjectService::cancel_operation][crate::client::ProjectService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::project_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProjectService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "rank-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "rank-service")))]
pub mod rank_service {
    use crate::Result;

    /// A builder for [RankService][crate::client::RankService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::rank_service::ClientBuilder;
    /// # use client::RankService;
    /// let builder : ClientBuilder = RankService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::RankService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = RankService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::RankService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [RankService::rank][crate::client::RankService::rank] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::rank_service::Rank;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Rank {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Rank(RequestBuilder<crate::model::RankRequest>);

    impl Rank {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RankRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::RankResponse> {
            (*self.0.stub)
                .rank(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [ranking_config][crate::model::RankRequest::ranking_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_ranking_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.ranking_config = v.into();
            self
        }

        /// Sets the value of [model][crate::model::RankRequest::model].
        pub fn set_model<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model = v.into();
            self
        }

        /// Sets the value of [top_n][crate::model::RankRequest::top_n].
        pub fn set_top_n<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.top_n = v.into();
            self
        }

        /// Sets the value of [query][crate::model::RankRequest::query].
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [records][crate::model::RankRequest::records].
        ///
        /// This is a **required** field for requests.
        pub fn set_records<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::RankingRecord>,
        {
            use std::iter::Iterator;
            self.0.request.records = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [ignore_record_details_in_response][crate::model::RankRequest::ignore_record_details_in_response].
        pub fn set_ignore_record_details_in_response<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.ignore_record_details_in_response = v.into();
            self
        }

        /// Sets the value of [user_labels][crate::model::RankRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Rank {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RankService::list_operations][crate::client::RankService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::rank_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RankService::get_operation][crate::client::RankService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::rank_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RankService::cancel_operation][crate::client::RankService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::rank_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RankService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "recommendation-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "recommendation-service")))]
pub mod recommendation_service {
    use crate::Result;

    /// A builder for [RecommendationService][crate::client::RecommendationService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::recommendation_service::ClientBuilder;
    /// # use client::RecommendationService;
    /// let builder : ClientBuilder = RecommendationService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::RecommendationService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = RecommendationService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::RecommendationService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [RecommendationService::recommend][crate::client::RecommendationService::recommend] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::recommendation_service::Recommend;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Recommend {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Recommend(RequestBuilder<crate::model::RecommendRequest>);

    impl Recommend {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RecommendRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::RecommendResponse> {
            (*self.0.stub)
                .recommend(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::RecommendRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::RecommendRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_event][crate::model::RecommendRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_user_event<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_size][crate::model::RecommendRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::RecommendRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [validate_only][crate::model::RecommendRequest::validate_only].
        pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.validate_only = v.into();
            self
        }

        /// Sets the value of [params][crate::model::RecommendRequest::params].
        pub fn set_params<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<wkt::Value>,
        {
            self.0.request.params = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [user_labels][crate::model::RecommendRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Recommend {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RecommendationService::list_operations][crate::client::RecommendationService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::recommendation_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RecommendationService::get_operation][crate::client::RecommendationService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::recommendation_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [RecommendationService::cancel_operation][crate::client::RecommendationService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::recommendation_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::RecommendationService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "schema-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "schema-service")))]
pub mod schema_service {
    use crate::Result;

    /// A builder for [SchemaService][crate::client::SchemaService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::schema_service::ClientBuilder;
    /// # use client::SchemaService;
    /// let builder : ClientBuilder = SchemaService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SchemaService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SchemaService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SchemaService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SchemaService::get_schema][crate::client::SchemaService::get_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::GetSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSchema(RequestBuilder<crate::model::GetSchemaRequest>);

    impl GetSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .get_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::list_schemas][crate::client::SchemaService::list_schemas] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::ListSchemas;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSchemas {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSchemas(RequestBuilder<crate::model::ListSchemasRequest>);

    impl ListSchemas {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSchemasRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSchemasResponse> {
            (*self.0.stub)
                .list_schemas(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSchemasResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSchemasResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListSchemasRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSchemasRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSchemasRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSchemas {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::create_schema][crate::client::SchemaService::create_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::CreateSchema;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSchema(RequestBuilder<crate::model::CreateSchemaRequest>);

    impl CreateSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_schema][crate::client::SchemaService::create_schema].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_schema`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Schema, crate::model::CreateSchemaMetadata> {
            type Operation =
                lro::internal::Operation<crate::model::Schema, crate::model::CreateSchemaMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateSchemaRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [schema][crate::model::CreateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema][crate::model::CreateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = v.map(|x| x.into());
            self
        }

        /// Sets the value of [schema_id][crate::model::CreateSchemaRequest::schema_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.schema_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::update_schema][crate::client::SchemaService::update_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::UpdateSchema;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateSchema(RequestBuilder<crate::model::UpdateSchemaRequest>);

    impl UpdateSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [update_schema][crate::client::SchemaService::update_schema].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .update_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `update_schema`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Schema, crate::model::UpdateSchemaMetadata> {
            type Operation =
                lro::internal::Operation<crate::model::Schema, crate::model::UpdateSchemaMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [schema][crate::model::UpdateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema][crate::model::UpdateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::UpdateSchemaRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::delete_schema][crate::client::SchemaService::delete_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::DeleteSchema;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSchema(RequestBuilder<crate::model::DeleteSchemaRequest>);

    impl DeleteSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_schema][crate::client::SchemaService::delete_schema].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_schema`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteSchemaMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteSchemaMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::list_operations][crate::client::SchemaService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::get_operation][crate::client::SchemaService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::cancel_operation][crate::client::SchemaService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::schema_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "search-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "search-service")))]
pub mod search_service {
    use crate::Result;

    /// A builder for [SearchService][crate::client::SearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::search_service::ClientBuilder;
    /// # use client::SearchService;
    /// let builder : ClientBuilder = SearchService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SearchService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SearchService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SearchService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SearchService::search][crate::client::SearchService::search] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_service::Search;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Search {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Search(RequestBuilder<crate::model::SearchRequest>);

    impl Search {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SearchRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SearchResponse> {
            (*self.0.stub)
                .search(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::SearchResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::SearchResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [serving_config][crate::model::SearchRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [branch][crate::model::SearchRequest::branch].
        pub fn set_branch<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.branch = v.into();
            self
        }

        /// Sets the value of [query][crate::model::SearchRequest::query].
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [image_query][crate::model::SearchRequest::image_query].
        pub fn set_image_query<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ImageQuery>,
        {
            self.0.request.image_query = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [image_query][crate::model::SearchRequest::image_query].
        pub fn set_or_clear_image_query<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ImageQuery>,
        {
            self.0.request.image_query = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_size][crate::model::SearchRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::SearchRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [offset][crate::model::SearchRequest::offset].
        pub fn set_offset<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.offset = v.into();
            self
        }

        /// Sets the value of [one_box_page_size][crate::model::SearchRequest::one_box_page_size].
        pub fn set_one_box_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.one_box_page_size = v.into();
            self
        }

        /// Sets the value of [data_store_specs][crate::model::SearchRequest::data_store_specs].
        pub fn set_data_store_specs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::search_request::DataStoreSpec>,
        {
            use std::iter::Iterator;
            self.0.request.data_store_specs = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [filter][crate::model::SearchRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [canonical_filter][crate::model::SearchRequest::canonical_filter].
        pub fn set_canonical_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.canonical_filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::SearchRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }

        /// Sets the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_user_info<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_or_clear_user_info<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = v.map(|x| x.into());
            self
        }

        /// Sets the value of [language_code][crate::model::SearchRequest::language_code].
        pub fn set_language_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.language_code = v.into();
            self
        }

        /// Sets the value of [facet_specs][crate::model::SearchRequest::facet_specs].
        pub fn set_facet_specs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::search_request::FacetSpec>,
        {
            use std::iter::Iterator;
            self.0.request.facet_specs = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_boost_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_or_clear_boost_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [params][crate::model::SearchRequest::params].
        pub fn set_params<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<wkt::Value>,
        {
            self.0.request.params = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_query_expansion_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_or_clear_query_expansion_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_spell_correction_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_or_clear_spell_correction_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [user_pseudo_id][crate::model::SearchRequest::user_pseudo_id].
        pub fn set_user_pseudo_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_pseudo_id = v.into();
            self
        }

        /// Sets the value of [content_search_spec][crate::model::SearchRequest::content_search_spec].
        pub fn set_content_search_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ContentSearchSpec>,
        {
            self.0.request.content_search_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [content_search_spec][crate::model::SearchRequest::content_search_spec].
        pub fn set_or_clear_content_search_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ContentSearchSpec>,
        {
            self.0.request.content_search_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [safe_search][crate::model::SearchRequest::safe_search].
        pub fn set_safe_search<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.safe_search = v.into();
            self
        }

        /// Sets the value of [user_labels][crate::model::SearchRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [search_as_you_type_spec][crate::model::SearchRequest::search_as_you_type_spec].
        pub fn set_search_as_you_type_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SearchAsYouTypeSpec>,
        {
            self.0.request.search_as_you_type_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [search_as_you_type_spec][crate::model::SearchRequest::search_as_you_type_spec].
        pub fn set_or_clear_search_as_you_type_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SearchAsYouTypeSpec>,
        {
            self.0.request.search_as_you_type_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [display_spec][crate::model::SearchRequest::display_spec].
        pub fn set_display_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DisplaySpec>,
        {
            self.0.request.display_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [display_spec][crate::model::SearchRequest::display_spec].
        pub fn set_or_clear_display_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DisplaySpec>,
        {
            self.0.request.display_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [session][crate::model::SearchRequest::session].
        pub fn set_session<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.session = v.into();
            self
        }

        /// Sets the value of [session_spec][crate::model::SearchRequest::session_spec].
        pub fn set_session_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SessionSpec>,
        {
            self.0.request.session_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session_spec][crate::model::SearchRequest::session_spec].
        pub fn set_or_clear_session_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SessionSpec>,
        {
            self.0.request.session_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [relevance_threshold][crate::model::SearchRequest::relevance_threshold].
        pub fn set_relevance_threshold<
            T: Into<crate::model::search_request::RelevanceThreshold>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.relevance_threshold = v.into();
            self
        }

        /// Sets the value of [relevance_score_spec][crate::model::SearchRequest::relevance_score_spec].
        pub fn set_relevance_score_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::RelevanceScoreSpec>,
        {
            self.0.request.relevance_score_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [relevance_score_spec][crate::model::SearchRequest::relevance_score_spec].
        pub fn set_or_clear_relevance_score_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::RelevanceScoreSpec>,
        {
            self.0.request.relevance_score_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ranking_expression][crate::model::SearchRequest::ranking_expression].
        pub fn set_ranking_expression<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.ranking_expression = v.into();
            self
        }

        /// Sets the value of [ranking_expression_backend][crate::model::SearchRequest::ranking_expression_backend].
        pub fn set_ranking_expression_backend<
            T: Into<crate::model::search_request::RankingExpressionBackend>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.ranking_expression_backend = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Search {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::search_lite][crate::client::SearchService::search_lite] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_service::SearchLite;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SearchLite {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SearchLite(RequestBuilder<crate::model::SearchRequest>);

    impl SearchLite {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SearchRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SearchResponse> {
            (*self.0.stub)
                .search_lite(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::SearchResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::SearchResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [serving_config][crate::model::SearchRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [branch][crate::model::SearchRequest::branch].
        pub fn set_branch<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.branch = v.into();
            self
        }

        /// Sets the value of [query][crate::model::SearchRequest::query].
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [image_query][crate::model::SearchRequest::image_query].
        pub fn set_image_query<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ImageQuery>,
        {
            self.0.request.image_query = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [image_query][crate::model::SearchRequest::image_query].
        pub fn set_or_clear_image_query<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ImageQuery>,
        {
            self.0.request.image_query = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_size][crate::model::SearchRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::SearchRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [offset][crate::model::SearchRequest::offset].
        pub fn set_offset<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.offset = v.into();
            self
        }

        /// Sets the value of [one_box_page_size][crate::model::SearchRequest::one_box_page_size].
        pub fn set_one_box_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.one_box_page_size = v.into();
            self
        }

        /// Sets the value of [data_store_specs][crate::model::SearchRequest::data_store_specs].
        pub fn set_data_store_specs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::search_request::DataStoreSpec>,
        {
            use std::iter::Iterator;
            self.0.request.data_store_specs = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [filter][crate::model::SearchRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [canonical_filter][crate::model::SearchRequest::canonical_filter].
        pub fn set_canonical_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.canonical_filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::SearchRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }

        /// Sets the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_user_info<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_or_clear_user_info<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = v.map(|x| x.into());
            self
        }

        /// Sets the value of [language_code][crate::model::SearchRequest::language_code].
        pub fn set_language_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.language_code = v.into();
            self
        }

        /// Sets the value of [facet_specs][crate::model::SearchRequest::facet_specs].
        pub fn set_facet_specs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::search_request::FacetSpec>,
        {
            use std::iter::Iterator;
            self.0.request.facet_specs = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_boost_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_or_clear_boost_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [params][crate::model::SearchRequest::params].
        pub fn set_params<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<wkt::Value>,
        {
            self.0.request.params = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_query_expansion_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_or_clear_query_expansion_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_spell_correction_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_or_clear_spell_correction_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [user_pseudo_id][crate::model::SearchRequest::user_pseudo_id].
        pub fn set_user_pseudo_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_pseudo_id = v.into();
            self
        }

        /// Sets the value of [content_search_spec][crate::model::SearchRequest::content_search_spec].
        pub fn set_content_search_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ContentSearchSpec>,
        {
            self.0.request.content_search_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [content_search_spec][crate::model::SearchRequest::content_search_spec].
        pub fn set_or_clear_content_search_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ContentSearchSpec>,
        {
            self.0.request.content_search_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [safe_search][crate::model::SearchRequest::safe_search].
        pub fn set_safe_search<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.safe_search = v.into();
            self
        }

        /// Sets the value of [user_labels][crate::model::SearchRequest::user_labels].
        pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [search_as_you_type_spec][crate::model::SearchRequest::search_as_you_type_spec].
        pub fn set_search_as_you_type_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SearchAsYouTypeSpec>,
        {
            self.0.request.search_as_you_type_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [search_as_you_type_spec][crate::model::SearchRequest::search_as_you_type_spec].
        pub fn set_or_clear_search_as_you_type_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SearchAsYouTypeSpec>,
        {
            self.0.request.search_as_you_type_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [display_spec][crate::model::SearchRequest::display_spec].
        pub fn set_display_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DisplaySpec>,
        {
            self.0.request.display_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [display_spec][crate::model::SearchRequest::display_spec].
        pub fn set_or_clear_display_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DisplaySpec>,
        {
            self.0.request.display_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [session][crate::model::SearchRequest::session].
        pub fn set_session<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.session = v.into();
            self
        }

        /// Sets the value of [session_spec][crate::model::SearchRequest::session_spec].
        pub fn set_session_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SessionSpec>,
        {
            self.0.request.session_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session_spec][crate::model::SearchRequest::session_spec].
        pub fn set_or_clear_session_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SessionSpec>,
        {
            self.0.request.session_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [relevance_threshold][crate::model::SearchRequest::relevance_threshold].
        pub fn set_relevance_threshold<
            T: Into<crate::model::search_request::RelevanceThreshold>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.relevance_threshold = v.into();
            self
        }

        /// Sets the value of [relevance_score_spec][crate::model::SearchRequest::relevance_score_spec].
        pub fn set_relevance_score_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::RelevanceScoreSpec>,
        {
            self.0.request.relevance_score_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [relevance_score_spec][crate::model::SearchRequest::relevance_score_spec].
        pub fn set_or_clear_relevance_score_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::RelevanceScoreSpec>,
        {
            self.0.request.relevance_score_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ranking_expression][crate::model::SearchRequest::ranking_expression].
        pub fn set_ranking_expression<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.ranking_expression = v.into();
            self
        }

        /// Sets the value of [ranking_expression_backend][crate::model::SearchRequest::ranking_expression_backend].
        pub fn set_ranking_expression_backend<
            T: Into<crate::model::search_request::RankingExpressionBackend>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.ranking_expression_backend = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SearchLite {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::list_operations][crate::client::SearchService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::get_operation][crate::client::SearchService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::cancel_operation][crate::client::SearchService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "search-tuning-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "search-tuning-service")))]
pub mod search_tuning_service {
    use crate::Result;

    /// A builder for [SearchTuningService][crate::client::SearchTuningService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::search_tuning_service::ClientBuilder;
    /// # use client::SearchTuningService;
    /// let builder : ClientBuilder = SearchTuningService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SearchTuningService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SearchTuningService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SearchTuningService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SearchTuningService::train_custom_model][crate::client::SearchTuningService::train_custom_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_tuning_service::TrainCustomModel;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> TrainCustomModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct TrainCustomModel(RequestBuilder<crate::model::TrainCustomModelRequest>);

    impl TrainCustomModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::TrainCustomModelRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [train_custom_model][crate::client::SearchTuningService::train_custom_model].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .train_custom_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `train_custom_model`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::TrainCustomModelResponse,
            crate::model::TrainCustomModelMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::TrainCustomModelResponse,
                crate::model::TrainCustomModelMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [data_store][crate::model::TrainCustomModelRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.data_store = v.into();
            self
        }

        /// Sets the value of [model_type][crate::model::TrainCustomModelRequest::model_type].
        pub fn set_model_type<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model_type = v.into();
            self
        }

        /// Sets the value of [error_config][crate::model::TrainCustomModelRequest::error_config].
        pub fn set_error_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error_config][crate::model::TrainCustomModelRequest::error_config].
        pub fn set_or_clear_error_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [model_id][crate::model::TrainCustomModelRequest::model_id].
        pub fn set_model_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.model_id = v.into();
            self
        }

        /// Sets the value of [training_input][crate::model::TrainCustomModelRequest::training_input].
        ///
        /// Note that all the setters affecting `training_input` are
        /// mutually exclusive.
        pub fn set_training_input<
            T: Into<Option<crate::model::train_custom_model_request::TrainingInput>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.training_input = v.into();
            self
        }

        /// Sets the value of [training_input][crate::model::TrainCustomModelRequest::training_input]
        /// to hold a `GcsTrainingInput`.
        ///
        /// Note that all the setters affecting `training_input` are
        /// mutually exclusive.
        pub fn set_gcs_training_input<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::train_custom_model_request::GcsTrainingInput>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_training_input(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for TrainCustomModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchTuningService::list_custom_models][crate::client::SearchTuningService::list_custom_models] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_tuning_service::ListCustomModels;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListCustomModels {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListCustomModels(RequestBuilder<crate::model::ListCustomModelsRequest>);

    impl ListCustomModels {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListCustomModelsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListCustomModelsResponse> {
            (*self.0.stub)
                .list_custom_models(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [data_store][crate::model::ListCustomModelsRequest::data_store].
        ///
        /// This is a **required** field for requests.
        pub fn set_data_store<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.data_store = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListCustomModels {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchTuningService::list_operations][crate::client::SearchTuningService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_tuning_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchTuningService::get_operation][crate::client::SearchTuningService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_tuning_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchTuningService::cancel_operation][crate::client::SearchTuningService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::search_tuning_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchTuningService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "serving-config-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "serving-config-service")))]
pub mod serving_config_service {
    use crate::Result;

    /// A builder for [ServingConfigService][crate::client::ServingConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::serving_config_service::ClientBuilder;
    /// # use client::ServingConfigService;
    /// let builder : ClientBuilder = ServingConfigService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ServingConfigService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ServingConfigService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ServingConfigService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ServingConfigService::update_serving_config][crate::client::ServingConfigService::update_serving_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::serving_config_service::UpdateServingConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateServingConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateServingConfig(RequestBuilder<crate::model::UpdateServingConfigRequest>);

    impl UpdateServingConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateServingConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .update_serving_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::UpdateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [serving_config][crate::model::UpdateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_serving_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateServingConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateServingConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateServingConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::list_operations][crate::client::ServingConfigService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::serving_config_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::get_operation][crate::client::ServingConfigService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::serving_config_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::cancel_operation][crate::client::ServingConfigService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::serving_config_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "session-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "session-service")))]
pub mod session_service {
    use crate::Result;

    /// A builder for [SessionService][crate::client::SessionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::session_service::ClientBuilder;
    /// # use client::SessionService;
    /// let builder : ClientBuilder = SessionService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SessionService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SessionService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SessionService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SessionService::create_session][crate::client::SessionService::create_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::CreateSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSession(RequestBuilder<crate::model::CreateSessionRequest>);

    impl CreateSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .create_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateSessionRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [session][crate::model::CreateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_session<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session][crate::model::CreateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::delete_session][crate::client::SessionService::delete_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::DeleteSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSession(RequestBuilder<crate::model::DeleteSessionRequest>);

    impl DeleteSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteSessionRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::update_session][crate::client::SessionService::update_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::UpdateSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateSession(RequestBuilder<crate::model::UpdateSessionRequest>);

    impl UpdateSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .update_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [session][crate::model::UpdateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_session<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [session][crate::model::UpdateSessionRequest::session].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Session>,
        {
            self.0.request.session = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateSessionRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateSessionRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::get_session][crate::client::SessionService::get_session] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::GetSession;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSession {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSession(RequestBuilder<crate::model::GetSessionRequest>);

    impl GetSession {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSessionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Session> {
            (*self.0.stub)
                .get_session(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetSessionRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [include_answer_details][crate::model::GetSessionRequest::include_answer_details].
        pub fn set_include_answer_details<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.include_answer_details = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSession {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::list_sessions][crate::client::SessionService::list_sessions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::ListSessions;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSessions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSessions(RequestBuilder<crate::model::ListSessionsRequest>);

    impl ListSessions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSessionsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSessionsResponse> {
            (*self.0.stub)
                .list_sessions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSessionsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSessionsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListSessionsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSessionsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSessionsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListSessionsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::ListSessionsRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSessions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::list_operations][crate::client::SessionService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::get_operation][crate::client::SessionService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SessionService::cancel_operation][crate::client::SessionService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::session_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SessionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "site-search-engine-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "site-search-engine-service")))]
pub mod site_search_engine_service {
    use crate::Result;

    /// A builder for [SiteSearchEngineService][crate::client::SiteSearchEngineService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::site_search_engine_service::ClientBuilder;
    /// # use client::SiteSearchEngineService;
    /// let builder : ClientBuilder = SiteSearchEngineService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SiteSearchEngineService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SiteSearchEngineService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SiteSearchEngineService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SiteSearchEngineService::get_site_search_engine][crate::client::SiteSearchEngineService::get_site_search_engine] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::GetSiteSearchEngine;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSiteSearchEngine {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSiteSearchEngine(RequestBuilder<crate::model::GetSiteSearchEngineRequest>);

    impl GetSiteSearchEngine {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSiteSearchEngineRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SiteSearchEngine> {
            (*self.0.stub)
                .get_site_search_engine(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetSiteSearchEngineRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSiteSearchEngine {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::create_target_site][crate::client::SiteSearchEngineService::create_target_site] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::CreateTargetSite;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateTargetSite {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateTargetSite(RequestBuilder<crate::model::CreateTargetSiteRequest>);

    impl CreateTargetSite {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateTargetSiteRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_target_site][crate::client::SiteSearchEngineService::create_target_site].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_target_site(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_target_site`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::TargetSite, crate::model::CreateTargetSiteMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::TargetSite,
                crate::model::CreateTargetSiteMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateTargetSiteRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [target_site][crate::model::CreateTargetSiteRequest::target_site].
        ///
        /// This is a **required** field for requests.
        pub fn set_target_site<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::TargetSite>,
        {
            self.0.request.target_site = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [target_site][crate::model::CreateTargetSiteRequest::target_site].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_target_site<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::TargetSite>,
        {
            self.0.request.target_site = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateTargetSite {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::batch_create_target_sites][crate::client::SiteSearchEngineService::batch_create_target_sites] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::BatchCreateTargetSites;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchCreateTargetSites {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchCreateTargetSites(RequestBuilder<crate::model::BatchCreateTargetSitesRequest>);

    impl BatchCreateTargetSites {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchCreateTargetSitesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [batch_create_target_sites][crate::client::SiteSearchEngineService::batch_create_target_sites].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .batch_create_target_sites(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `batch_create_target_sites`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::BatchCreateTargetSitesResponse,
            crate::model::BatchCreateTargetSiteMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::BatchCreateTargetSitesResponse,
                crate::model::BatchCreateTargetSiteMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::BatchCreateTargetSitesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [requests][crate::model::BatchCreateTargetSitesRequest::requests].
        ///
        /// This is a **required** field for requests.
        pub fn set_requests<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::CreateTargetSiteRequest>,
        {
            use std::iter::Iterator;
            self.0.request.requests = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchCreateTargetSites {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::get_target_site][crate::client::SiteSearchEngineService::get_target_site] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::GetTargetSite;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetTargetSite {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetTargetSite(RequestBuilder<crate::model::GetTargetSiteRequest>);

    impl GetTargetSite {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetTargetSiteRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::TargetSite> {
            (*self.0.stub)
                .get_target_site(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetTargetSiteRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetTargetSite {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::update_target_site][crate::client::SiteSearchEngineService::update_target_site] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::UpdateTargetSite;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateTargetSite {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateTargetSite(RequestBuilder<crate::model::UpdateTargetSiteRequest>);

    impl UpdateTargetSite {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateTargetSiteRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [update_target_site][crate::client::SiteSearchEngineService::update_target_site].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .update_target_site(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `update_target_site`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::TargetSite, crate::model::UpdateTargetSiteMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::TargetSite,
                crate::model::UpdateTargetSiteMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [target_site][crate::model::UpdateTargetSiteRequest::target_site].
        ///
        /// This is a **required** field for requests.
        pub fn set_target_site<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::TargetSite>,
        {
            self.0.request.target_site = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [target_site][crate::model::UpdateTargetSiteRequest::target_site].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_target_site<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::TargetSite>,
        {
            self.0.request.target_site = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateTargetSite {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::delete_target_site][crate::client::SiteSearchEngineService::delete_target_site] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::DeleteTargetSite;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteTargetSite {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteTargetSite(RequestBuilder<crate::model::DeleteTargetSiteRequest>);

    impl DeleteTargetSite {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteTargetSiteRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_target_site][crate::client::SiteSearchEngineService::delete_target_site].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_target_site(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_target_site`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteTargetSiteMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteTargetSiteMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteTargetSiteRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteTargetSite {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::list_target_sites][crate::client::SiteSearchEngineService::list_target_sites] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::ListTargetSites;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListTargetSites {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTargetSites(RequestBuilder<crate::model::ListTargetSitesRequest>);

    impl ListTargetSites {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListTargetSitesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListTargetSitesResponse> {
            (*self.0.stub)
                .list_target_sites(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListTargetSitesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListTargetSitesResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListTargetSitesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListTargetSitesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListTargetSitesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListTargetSites {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::create_sitemap][crate::client::SiteSearchEngineService::create_sitemap] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::CreateSitemap;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSitemap {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSitemap(RequestBuilder<crate::model::CreateSitemapRequest>);

    impl CreateSitemap {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSitemapRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_sitemap][crate::client::SiteSearchEngineService::create_sitemap].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_sitemap(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_sitemap`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Sitemap, crate::model::CreateSitemapMetadata> {
            type Operation = lro::internal::Operation<
                crate::model::Sitemap,
                crate::model::CreateSitemapMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateSitemapRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [sitemap][crate::model::CreateSitemapRequest::sitemap].
        ///
        /// This is a **required** field for requests.
        pub fn set_sitemap<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Sitemap>,
        {
            self.0.request.sitemap = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [sitemap][crate::model::CreateSitemapRequest::sitemap].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_sitemap<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Sitemap>,
        {
            self.0.request.sitemap = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSitemap {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::delete_sitemap][crate::client::SiteSearchEngineService::delete_sitemap] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::DeleteSitemap;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSitemap {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSitemap(RequestBuilder<crate::model::DeleteSitemapRequest>);

    impl DeleteSitemap {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSitemapRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [delete_sitemap][crate::client::SiteSearchEngineService::delete_sitemap].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .delete_sitemap(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `delete_sitemap`.
        pub fn poller(self) -> impl lro::Poller<(), crate::model::DeleteSitemapMetadata> {
            type Operation =
                lro::internal::Operation<wkt::Empty, crate::model::DeleteSitemapMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_unit_response_poller(
                polling_error_policy,
                polling_backoff_policy,
                start,
                query,
            )
        }

        /// Sets the value of [name][crate::model::DeleteSitemapRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSitemap {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::fetch_sitemaps][crate::client::SiteSearchEngineService::fetch_sitemaps] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::FetchSitemaps;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> FetchSitemaps {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct FetchSitemaps(RequestBuilder<crate::model::FetchSitemapsRequest>);

    impl FetchSitemaps {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::FetchSitemapsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::FetchSitemapsResponse> {
            (*self.0.stub)
                .fetch_sitemaps(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::FetchSitemapsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [matcher][crate::model::FetchSitemapsRequest::matcher].
        pub fn set_matcher<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::fetch_sitemaps_request::Matcher>,
        {
            self.0.request.matcher = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [matcher][crate::model::FetchSitemapsRequest::matcher].
        pub fn set_or_clear_matcher<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::fetch_sitemaps_request::Matcher>,
        {
            self.0.request.matcher = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for FetchSitemaps {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::enable_advanced_site_search][crate::client::SiteSearchEngineService::enable_advanced_site_search] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::EnableAdvancedSiteSearch;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> EnableAdvancedSiteSearch {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct EnableAdvancedSiteSearch(
        RequestBuilder<crate::model::EnableAdvancedSiteSearchRequest>,
    );

    impl EnableAdvancedSiteSearch {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::EnableAdvancedSiteSearchRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [enable_advanced_site_search][crate::client::SiteSearchEngineService::enable_advanced_site_search].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .enable_advanced_site_search(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `enable_advanced_site_search`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::EnableAdvancedSiteSearchResponse,
            crate::model::EnableAdvancedSiteSearchMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::EnableAdvancedSiteSearchResponse,
                crate::model::EnableAdvancedSiteSearchMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [site_search_engine][crate::model::EnableAdvancedSiteSearchRequest::site_search_engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_site_search_engine<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.site_search_engine = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for EnableAdvancedSiteSearch {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::disable_advanced_site_search][crate::client::SiteSearchEngineService::disable_advanced_site_search] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::DisableAdvancedSiteSearch;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DisableAdvancedSiteSearch {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DisableAdvancedSiteSearch(
        RequestBuilder<crate::model::DisableAdvancedSiteSearchRequest>,
    );

    impl DisableAdvancedSiteSearch {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DisableAdvancedSiteSearchRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [disable_advanced_site_search][crate::client::SiteSearchEngineService::disable_advanced_site_search].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .disable_advanced_site_search(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `disable_advanced_site_search`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::DisableAdvancedSiteSearchResponse,
            crate::model::DisableAdvancedSiteSearchMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::DisableAdvancedSiteSearchResponse,
                crate::model::DisableAdvancedSiteSearchMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [site_search_engine][crate::model::DisableAdvancedSiteSearchRequest::site_search_engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_site_search_engine<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.site_search_engine = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DisableAdvancedSiteSearch {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::recrawl_uris][crate::client::SiteSearchEngineService::recrawl_uris] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::RecrawlUris;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RecrawlUris {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RecrawlUris(RequestBuilder<crate::model::RecrawlUrisRequest>);

    impl RecrawlUris {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RecrawlUrisRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [recrawl_uris][crate::client::SiteSearchEngineService::recrawl_uris].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .recrawl_uris(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `recrawl_uris`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::RecrawlUrisResponse, crate::model::RecrawlUrisMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::RecrawlUrisResponse,
                crate::model::RecrawlUrisMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [site_search_engine][crate::model::RecrawlUrisRequest::site_search_engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_site_search_engine<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.site_search_engine = v.into();
            self
        }

        /// Sets the value of [uris][crate::model::RecrawlUrisRequest::uris].
        ///
        /// This is a **required** field for requests.
        pub fn set_uris<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.uris = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [site_credential][crate::model::RecrawlUrisRequest::site_credential].
        pub fn set_site_credential<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.site_credential = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RecrawlUris {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::batch_verify_target_sites][crate::client::SiteSearchEngineService::batch_verify_target_sites] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::BatchVerifyTargetSites;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchVerifyTargetSites {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchVerifyTargetSites(RequestBuilder<crate::model::BatchVerifyTargetSitesRequest>);

    impl BatchVerifyTargetSites {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchVerifyTargetSitesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [batch_verify_target_sites][crate::client::SiteSearchEngineService::batch_verify_target_sites].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .batch_verify_target_sites(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `batch_verify_target_sites`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::BatchVerifyTargetSitesResponse,
            crate::model::BatchVerifyTargetSitesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::BatchVerifyTargetSitesResponse,
                crate::model::BatchVerifyTargetSitesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::BatchVerifyTargetSitesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchVerifyTargetSites {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::fetch_domain_verification_status][crate::client::SiteSearchEngineService::fetch_domain_verification_status] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::FetchDomainVerificationStatus;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> FetchDomainVerificationStatus {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct FetchDomainVerificationStatus(
        RequestBuilder<crate::model::FetchDomainVerificationStatusRequest>,
    );

    impl FetchDomainVerificationStatus {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::FetchDomainVerificationStatusRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::FetchDomainVerificationStatusResponse> {
            (*self.0.stub)
                .fetch_domain_verification_status(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<
            crate::model::FetchDomainVerificationStatusResponse,
            gax::error::Error,
        > {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::FetchDomainVerificationStatusResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [site_search_engine][crate::model::FetchDomainVerificationStatusRequest::site_search_engine].
        ///
        /// This is a **required** field for requests.
        pub fn set_site_search_engine<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.site_search_engine = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::FetchDomainVerificationStatusRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::FetchDomainVerificationStatusRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for FetchDomainVerificationStatus {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::list_operations][crate::client::SiteSearchEngineService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::get_operation][crate::client::SiteSearchEngineService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SiteSearchEngineService::cancel_operation][crate::client::SiteSearchEngineService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::site_search_engine_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SiteSearchEngineService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "user-event-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "user-event-service")))]
pub mod user_event_service {
    use crate::Result;

    /// A builder for [UserEventService][crate::client::UserEventService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::user_event_service::ClientBuilder;
    /// # use client::UserEventService;
    /// let builder : ClientBuilder = UserEventService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::UserEventService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = UserEventService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::UserEventService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [UserEventService::write_user_event][crate::client::UserEventService::write_user_event] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::WriteUserEvent;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> WriteUserEvent {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct WriteUserEvent(RequestBuilder<crate::model::WriteUserEventRequest>);

    impl WriteUserEvent {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::WriteUserEventRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::UserEvent> {
            (*self.0.stub)
                .write_user_event(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::WriteUserEventRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::WriteUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_event][crate::model::WriteUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_user_event<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = v.map(|x| x.into());
            self
        }

        /// Sets the value of [write_async][crate::model::WriteUserEventRequest::write_async].
        pub fn set_write_async<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.write_async = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for WriteUserEvent {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::collect_user_event][crate::client::UserEventService::collect_user_event] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::CollectUserEvent;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CollectUserEvent {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CollectUserEvent(RequestBuilder<crate::model::CollectUserEventRequest>);

    impl CollectUserEvent {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CollectUserEventRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<api::model::HttpBody> {
            (*self.0.stub)
                .collect_user_event(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CollectUserEventRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::CollectUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_event = v.into();
            self
        }

        /// Sets the value of [uri][crate::model::CollectUserEventRequest::uri].
        pub fn set_uri<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<std::string::String>,
        {
            self.0.request.uri = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [uri][crate::model::CollectUserEventRequest::uri].
        pub fn set_or_clear_uri<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<std::string::String>,
        {
            self.0.request.uri = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ets][crate::model::CollectUserEventRequest::ets].
        pub fn set_ets<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<i64>,
        {
            self.0.request.ets = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [ets][crate::model::CollectUserEventRequest::ets].
        pub fn set_or_clear_ets<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<i64>,
        {
            self.0.request.ets = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CollectUserEvent {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::purge_user_events][crate::client::UserEventService::purge_user_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::PurgeUserEvents;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeUserEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeUserEvents(RequestBuilder<crate::model::PurgeUserEventsRequest>);

    impl PurgeUserEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeUserEventsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_user_events][crate::client::UserEventService::purge_user_events].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_user_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_user_events`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::PurgeUserEventsResponse, crate::model::PurgeUserEventsMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::PurgeUserEventsResponse,
                crate::model::PurgeUserEventsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeUserEventsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PurgeUserEventsRequest::filter].
        ///
        /// This is a **required** field for requests.
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [force][crate::model::PurgeUserEventsRequest::force].
        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeUserEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::import_user_events][crate::client::UserEventService::import_user_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::ImportUserEvents;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportUserEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportUserEvents(RequestBuilder<crate::model::ImportUserEventsRequest>);

    impl ImportUserEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportUserEventsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_user_events][crate::client::UserEventService::import_user_events].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_user_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_user_events`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::ImportUserEventsResponse,
            crate::model::ImportUserEventsMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::ImportUserEventsResponse,
                crate::model::ImportUserEventsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportUserEventsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [error_config][crate::model::ImportUserEventsRequest::error_config].
        pub fn set_error_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error_config][crate::model::ImportUserEventsRequest::error_config].
        pub fn set_or_clear_error_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorConfig>,
        {
            self.0.request.error_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [source][crate::model::ImportUserEventsRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<T: Into<Option<crate::model::import_user_events_request::Source>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::ImportUserEventsRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::import_user_events_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportUserEventsRequest::source]
        /// to hold a `GcsSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_gcs_source(v);
            self
        }

        /// Sets the value of [source][crate::model::ImportUserEventsRequest::source]
        /// to hold a `BigquerySource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_bigquery_source<
            T: std::convert::Into<std::boxed::Box<crate::model::BigQuerySource>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_bigquery_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportUserEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::list_operations][crate::client::UserEventService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::get_operation][crate::client::UserEventService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::cancel_operation][crate::client::UserEventService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_event_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

#[cfg(feature = "user-license-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "user-license-service")))]
pub mod user_license_service {
    use crate::Result;

    /// A builder for [UserLicenseService][crate::client::UserLicenseService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::*;
    /// # use builder::user_license_service::ClientBuilder;
    /// # use client::UserLicenseService;
    /// let builder : ClientBuilder = UserLicenseService::builder();
    /// let client = builder
    ///     .with_endpoint("https://discoveryengine.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::UserLicenseService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = UserLicenseService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::UserLicenseService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [UserLicenseService::list_user_licenses][crate::client::UserLicenseService::list_user_licenses] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_license_service::ListUserLicenses;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListUserLicenses {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListUserLicenses(RequestBuilder<crate::model::ListUserLicensesRequest>);

    impl ListUserLicenses {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListUserLicensesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListUserLicensesResponse> {
            (*self.0.stub)
                .list_user_licenses(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListUserLicensesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListUserLicensesResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListUserLicensesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListUserLicensesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListUserLicensesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListUserLicensesRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListUserLicenses {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserLicenseService::batch_update_user_licenses][crate::client::UserLicenseService::batch_update_user_licenses] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_license_service::BatchUpdateUserLicenses;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchUpdateUserLicenses {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchUpdateUserLicenses(
        RequestBuilder<crate::model::BatchUpdateUserLicensesRequest>,
    );

    impl BatchUpdateUserLicenses {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchUpdateUserLicensesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [batch_update_user_licenses][crate::client::UserLicenseService::batch_update_user_licenses].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .batch_update_user_licenses(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `batch_update_user_licenses`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::BatchUpdateUserLicensesResponse,
            crate::model::BatchUpdateUserLicensesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::BatchUpdateUserLicensesResponse,
                crate::model::BatchUpdateUserLicensesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::BatchUpdateUserLicensesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [delete_unassigned_user_licenses][crate::model::BatchUpdateUserLicensesRequest::delete_unassigned_user_licenses].
        pub fn set_delete_unassigned_user_licenses<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.delete_unassigned_user_licenses = v.into();
            self
        }

        /// Sets the value of [source][crate::model::BatchUpdateUserLicensesRequest::source].
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_source<
            T: Into<Option<crate::model::batch_update_user_licenses_request::Source>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.source = v.into();
            self
        }

        /// Sets the value of [source][crate::model::BatchUpdateUserLicensesRequest::source]
        /// to hold a `InlineSource`.
        ///
        /// Note that all the setters affecting `source` are
        /// mutually exclusive.
        pub fn set_inline_source<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::batch_update_user_licenses_request::InlineSource>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_inline_source(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchUpdateUserLicenses {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserLicenseService::list_operations][crate::client::UserLicenseService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_license_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserLicenseService::get_operation][crate::client::UserLicenseService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_license_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserLicenseService::cancel_operation][crate::client::UserLicenseService::cancel_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_discoveryengine_v1::builder;
    /// use builder::user_license_service::CancelOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CancelOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);

    impl CancelOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserLicenseService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .cancel_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CancelOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
